home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / p_man / cat3 / f90 / ffopen.z / ffopen
Text File  |  1998-10-30  |  8KB  |  173 lines

  1. FFOPEN(3C)                                             Last changed: 2-5-98
  2.  
  3.  
  4. NNAAMMEE
  5.      ffffooppeenn, ffffooppeennss, ffffcclloossee, ffffooppeennff, ffffcclloosseeff - Opens or closes a file
  6.      using flexible file I/O
  7.  
  8. SSYYNNOOPPSSIISS
  9.      ##iinncclluuddee <<ffccnnttll..hh>>
  10.      ##iinncclluuddee <<ffffiioo..hh>>
  11.  
  12.      UNICOS and UNICOS/mk systems:
  13.  
  14.         iinntt ffffooppeenn ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g [[,, iinntt _m_o_d_e
  15.         [[,, lloonngg _c_b_i_t_s [[,, ssttrruucctt ffffssww **_s_t_a_t]]]]]]));;
  16.  
  17.         iinntt ffffooppeennss ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g,, iinntt _m_o_d_e,,
  18.         lloonngg _c_b_i_t_s,, [[iinntt _c_b_l_k_s,,]] ssttrruucctt ffffssww **_s_t_a_t,, ccoonnsstt cchhaarr **_s_t_r));;
  19.  
  20.         ffffcclloossee ((iinntt _f_d [[,, ssttrruucctt ffffssww **_s_t_a_t]]));;
  21.  
  22.      IRIX systems:
  23.  
  24.         iinntt ffffooppeenn ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g [[,,mmooddee__tt _m_o_d_e]]));;
  25.  
  26.         iinntt ffffooppeennss ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g,, mmooddee__tt _m_o_d_e,,
  27.         lloonngg _c_b_i_t_s, iinntt _c_b_l_k_s,, ssttrruucctt ffffssww **_s_t_a_t,, ccoonnsstt cchhaarr **_s_t_r));;
  28.  
  29.         iinntt ffffcclloossee ((iinntt _f_d));;
  30.  
  31.      All systems:
  32.  
  33.         ffffcclloosseeff ((iinntt _f_d,, ssttrruucctt ffffssww **_s_t_a_t));;
  34.  
  35.         iinntt ffffooppeennff ((ccoonnsstt cchhaarr **_n_a_m_e,, iinntt _o_f_l_a_g ,, iinntt ,,mmooddee__tt _m_o_d_e lloonngg
  36.         _c_b_i_t_s,, iinntt _c_b_l_k_s,, ssttrruucctt ffffssww **_s_t_a_t));;
  37.  
  38. IIMMPPLLEEMMEENNTTAATTIIOONN
  39.      UNICOS, UNICOS/mk, and IRIX systems
  40.  
  41. DDEESSCCRRIIPPTTIIOONN
  42.      The ffffooppeenn and ffffooppeennss functions open a file using flexible file I/O
  43.      (FFIO).  These functions are modeled after the ooppeenn(2) system call.
  44.      The file associated with _n_a_m_e is opened, and appropriate structures
  45.      are built to do special handling on the file.  For ffffooppeenn, the
  46.      processing layers to be used are as requested with the aassggccmmdd(1) or
  47.      aassssiiggnn(1) commands.  For ffffooppeennss, the layers are specified by the
  48.      string at _s_t_r.
  49.  
  50.      The ffffooppeenn function returns an integer.  Although it is not a file
  51.      descriptor, it is used in much the same way when passed to the other
  52.      functions such as ffffrreeaadd, ffffwwrriittee, or ffffcclloossee.
  53.  
  54.      The _o_f_l_a_g, _m_o_d_e, and _c_b_i_t_s parameters are exactly as in ooppeenn(2).
  55.  
  56.      On IRIX systems, the _c_b_i_t_s and _c_b_l_k_s parameters are ignored.
  57.  
  58.      The _s_t_a_t parameter is a pointer to a status return structure
  59.      containing a flag, an error indication, a transfer count, and an
  60.      indication of the condition that terminated the request.
  61.  
  62.      The ffffcclloossee and ffffcclloosseeff functions close the file associated with _f_d.
  63.      It does any necessary flushing and termination for that file.  Files
  64.      opened using ffffooppeenn(3C) are not guaranteed to be flushed at program
  65.      termination; call ffffcclloossee or ffffcclloosseeff to ensure this.
  66.  
  67. NNOOTTEESS
  68.      On IRIX systems, the FFIO routines are stored in lliibbffffiioo..ssoo, and are
  69.      available in the N32 and N64 ABIs.
  70.  
  71. RREETTUURRNN VVAALLUUEESS
  72.      Upon successful completion, a non-negative integer is returned; this
  73.      integer is currently a pointer to a control block.  Otherwise, -1 is
  74.      returned, and, if the _s_t_a_t parameter is passed, the error value is
  75.      found in ssttaatt..ssww__eerrrroorr.  If the _s_t_a_t parameter is not provided, the
  76.      error code is found in eerrrrnnoo.  The _s_t_a_t parameter is required for
  77.      ffffooppeennss() and ffffcclloosseeff.
  78.  
  79. EEXXAAMMPPLLEESS
  80.      To write a C program that will read the records of a COS blocked file
  81.      named iinnddaattaa and copy the data from the file (without blocking
  82.      information) to ssttddoouutt, compile the following program:
  83.  
  84.           #include <stdio.h>
  85.           #include <fcntl.h>
  86.           #include <ffio.h>
  87.  
  88.           #define BSZ 10000
  89.  
  90.           main()
  91.           {
  92.                 int fd, ret;
  93.                 char buf[BSZ];
  94.                 struct ffsw stat;
  95.                 int ubc = 0;
  96.  
  97.                 fd = ffopen("indata", O_RDONLY);
  98.                 do
  99.                 {
  100.                       ret = ffreadf(fd, buf, BSZ, &stat, PARTIAL, &ubc);
  101.                       fwrite(buf, 1, ret, stdout);
  102.                  } while (FFSTAT(stat) != FFEOD);
  103.                  ret = ffclose(fd);
  104.           }
  105.  
  106.      Use the following commands to compile, link, and run this program on
  107.      UNICOS and UNICOS/mk systems:
  108.  
  109.           $ cc cpy.c
  110.           $ eval `assign -F cos indata` # declare "indata" is COS blocked
  111.           $ a.out
  112.  
  113.      Use the following commands to compile, link, and run this program on
  114.      IRIX systems:
  115.  
  116.           $ cc cpy.c -lffio
  117.           $ eval `assign -F cos indata` # declare "indata" is COS blocked
  118.           $ a.out
  119.  
  120.      The same example program could be written to use the ffffooppeennss entry
  121.      point.  The layers to use in decoding the blocking information are
  122.      specified in the call, and not in the shell command aassggccmmdd(1), as
  123.      follows:
  124.  
  125.           #include <stdio.h>
  126.           #include <fcntl.h>
  127.           #include <ffio.h>
  128.  
  129.           #define BSZ 10000
  130.  
  131.           main()
  132.           {
  133.                 int fd, ret;
  134.                 char buf[BSZ];
  135.                 char *str;
  136.                 struct ffsw stat;
  137.                 int ubc = 0;
  138.  
  139.                 /* Set up to process COS blocked file. */
  140.                 str = "cos";
  141.                 fd = ffopens("indata", O_RDONLY, 0, 0L, 0, &stat, str);
  142.                 do
  143.                 {
  144.                       ret = ffreadf(fd, buf, BSZ, &stat, PARTIAL, &ubc);
  145.                       fwrite(buf, 1, ret, stdout);
  146.                 } while (FFSTAT(stat) != FFEOD);
  147.                 ret = ffclose(fd);
  148.           }
  149.  
  150.      Use the following commands on UNICOS and UNICOS/mk systems to compile,
  151.      link, and run this program:
  152.  
  153.           $ cc cpy.c
  154.           $ a.out
  155.  
  156.      Use the following commands on IRIX systems to compile, link, and run
  157.      this program:
  158.  
  159.           $ cc cpy.c -lffio
  160.  
  161. SSEEEE AALLSSOO
  162.      ffffrreeaadd(3C), ffffsseeeekk(3C)
  163.  
  164.      aassggccmmdd(1)
  165.  
  166.      ooppeenn(2) in the _U_N_I_C_O_S _S_y_s_t_e_m _C_a_l_l_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication
  167.      SR-2012
  168.  
  169.      _A_p_p_l_i_c_a_t_i_o_n _P_r_o_g_r_a_m_m_e_r'_s _I/_O _G_u_i_d_e, publication SG-2168
  170.  
  171.      _A_p_p_l_i_c_a_t_i_o_n _P_r_o_g_r_a_m_m_e_r'_s _L_i_b_r_a_r_y _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication
  172.      SR-2165, for the printed version of this man page.
  173.